<?php
/**
 * Class Adversiting controller
 *
 * @author NguyenVanTien
 */
class AdvertisingController extends Zend_Controller_Action {
    
    /**
     * Declarce $_modelAdvertising
     */
    protected $_modelAdvertising;
    
    public function init(){
        parent::init();
        
        //Instance model avertising
        $this->_modelAdvertising = new Application_Model_Advertising();
    }


    /**
     * Action default when load
     * @author Tien Nguyen
     */
    public function indexAction(){
        
    }
    
    /**
     * Action get last logo with number row per page is param get from url
     * @author Tien Nguyen
     */
    public function showListLastLogoAction(){
        //Get number row per page. If 'number-row-per-page' is empty, we will get 
        //param from config application 'row_per_one_page'
        $numberRowPerPage = $this->_request->getParam('number-row-per-page', 
                Zend_Registry::get('config')->rows_per_one_page);
        
        //Get list logo last
        $selectAdvertising = $this->_modelAdvertising->getListAdvertisingLogo();
        
        //Paging
        $paginator = Zend_Paginator::factory($selectAdvertising);       
        //Get config for number row in page
        $paginator->setItemCountPerPage($numberRowPerPage);
        $paginator->setPageRange(Zend_Registry::get('config')->number_page_in_paging);
        
        //Set view 
        $this->view->listAdvertisingLogo = $paginator;
    }
}